home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / imake / Imake.rules < prev    next >
Text File  |  1991-10-22  |  44KB  |  1,500 lines

  1. XCOMM -------------------------------------------------------------------------
  2. XCOMM Imake rules for building libraries, programs, scripts, and data files
  3. XCOMM rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  4.  
  5. /*
  6.  *           MACHINE-INDEPENDENT RULES; DO NOT MODIFY
  7.  *
  8.  * Warning, when defining rules: make sure you do not include both a trailing
  9.  * backslash and double ampersand backslash or else you will get an extra
  10.  * backslash in the Makefile.
  11.  * 
  12.  * The following macros are defined for the various templates and Imakefiles
  13.  * (for a list of the applicable make variables, see the template files):
  14.  * 
  15.  * SaberProgramTarget        (program,srclist,objlist,locallibs,syslibs)
  16.  * RemoveTargetProgram        (program)
  17.  * MakeDir            (dir)
  18.  * BuildIncludes        (srclist,dstsubdir,dstupdir)
  19.  * NormalProgramTarget        (program,objects,deplibs,locallibs,syslibs)
  20.  * SetUIDProgramTarget        (program,objects,deplibs,locallibs,syslibs)
  21.  * SingleProgramTarget        (program,objects,locallibs,syslibs)
  22.  * SimpleProgramTarget        (program)
  23.  * ComplexProgramTarget        (program)
  24.  * ComplexProgramTarget_1    (program,locallib,syslib)
  25.  * ComplexProgramTarget_2    (program,locallib,syslib)
  26.  * ComplexProgramTarget_3    (program,locallib,syslib)
  27.  * ServerTarget            (server,subdirs,objects,libs,syslibs)
  28.  * RanLibrary            (args)
  29.  * InstallLibrary        (libname,dest)
  30.  * MergeIntoInstalledLibrary    (tolib,fromlib)
  31.  * InstallLibraryAlias        (libname,alias,dest)
  32.  * InstallLintLibrary        (libname,dest)
  33.  * InstallManPageLong        (file,destdir,dest)
  34.  * InstallManPage        (file,destdir)
  35.  * InstallManPageAliases    (file,destdir,aliases)
  36.  * InstallNamedNonExec        (srcname,dstname,dest)
  37.  * InstallNonExecFile        (file,dest)
  38.  * InstallNonExec        (file,dest)
  39.  * InstallProgramWithFlags    (program,dest,flags)
  40.  * InstallProgram        (program,dest)
  41.  * InstallScript        (program,dest)
  42.  * InstallNamedProg        (srcname,dstname,dest)
  43.  * LinkFileList            (step,list,dir,sub)
  44.  * InstallMultipleDestFlags    (step,list,dest,flags)
  45.  * InstallMultipleDest        (step,list,dest)
  46.  * InstallMultiple        (list,dest)
  47.  * InstallMultipleFlags        (list,dest,flags)
  48.  * InstallMultipleMan        (list,dest)
  49.  * InstallAppDefaults        (class)
  50.  * InstallAppDefaultsLong    (file,class)
  51.  * DependDependency        ()
  52.  * DependTarget            ()
  53.  * DependTarget3        (srcs1,srcs2,srcs3)
  54.  * CleanTarget            ()
  55.  * TagsTarget            ()
  56.  * ImakeDependency        (target)
  57.  * BuildMakefileTarget        (notused,imakeflags)
  58.  * MakefileTarget        ()
  59.  * LibMkdir            (dir)
  60.  * LibCleanDir            (dir)
  61.  * ObjectCompile        (options)
  62.  * NormalLibObjCompile        (options)
  63.  * NormalSharedLibObjCompile    (options)
  64.  * LibObjCompile        (dir,options)
  65.  * DebuggedLibObjCompile    (options)
  66.  * ProfiledLibObjCompile    (options)
  67.  * SharedLibObjCompile        (options)
  68.  * NormalLibraryObjectRule    ()
  69.  * NormalFortranObjectRule    ()
  70.  * ObjectFromSpecialSource    (dst,src,flags)
  71.  * SpecialObjectRule        (objs,depends,options)
  72.  * NormalLibraryTarget        (libname,objlist)
  73.  * NormalLibraryTarget2        (libname,objlist1,objlist2)
  74.  * NormalLibraryTarget3        (libname,objlist1,objlist2,objlist3)
  75.  * NormalDepLibraryTarget    (libname,deplist,objlist)
  76.  * SubdirLibraryRule        (objlist)
  77.  * ProfiledLibraryTarget    (libname,objlist)
  78.  * DebuggedLibraryTarget    (libname,objlist)
  79.  * AliasedLibraryTarget        (libname,alias)
  80.  * NormalRelocatableTarget    (objname,objlist)
  81.  * ProfiledRelocatableTarget    (objname,objlist)
  82.  * DebuggedRelocatableTarget    (objname,objlist)
  83.  * LintLibraryTarget        (libname,srclist)
  84.  * NormalLintTarget        (srclist)
  85.  * LintTarget            ()
  86.  * LinkSourceFile        (src,dir)
  87.  * LinkFile            (tofile,fromfile)
  88.  * MakeSubincludesForBuild    (step,dir,srclist)
  89.  * NamedTargetSubdirs        (name,dirs,verb,flags,subname)
  90.  * NamedMakeSubdirs        (name,dirs)
  91.  * MakeSubdirs            (dirs)
  92.  * DependSubdirs        (dirs)
  93.  * ForceSubdirs            (dirs)
  94.  * InstallSubdirs        (dirs)
  95.  * InstallManSubdirs        (dirs)
  96.  * IncludesSubdirs        (dirs)
  97.  * NamedCleanSubdirs        (name,dirs)
  98.  * CleanSubdirs            (dirs)
  99.  * NamedTagSubdirs        (name,dirs)
  100.  * TagSubdirs            (dirs)
  101.  * MakeLintSubdirs        (dirs,target,subtarget)
  102.  * LintSubdirs            (dirs)
  103.  * MakeLintLibSubdirs        (dirs)
  104.  * MakeMakeSubdirs        (dirs,target)
  105.  * MakeNsubdirMakefiles        ()
  106.  * MakefileSubdirs        (dirs)
  107.  * CppScriptTarget        (dst,src,defs,deplist)
  108.  * MakeScriptFromCpp        (name,defs)
  109.  * CppFileTarget        (dst,src,defs,deplist)
  110.  * MakeDirectories        (step,dirs)
  111.  * MakeFontsDir            (deplist)
  112.  * MakeFonts            ()
  113.  * InstallFontObjs        (objs,dest)
  114.  * InstallFonts            (dest)
  115.  * InstallFontAliases        (dest)
  116.  * FontSrc            (basename)
  117.  * FontBaseObj            (basename)
  118.  * InstallFontScale        (dest)
  119.  * UncompressedFontTarget    (basename)
  120.  * UncompressedFontTarget    (basename)
  121.  * CompressedFontTarget        (basename)
  122.  * FontTarget            (basename)
  123.  * FontObj            (basename)
  124.  * AllTarget            (depends)
  125.  *
  126.  *
  127.  * The following are in Imake.tmpl:
  128.  *
  129.  * Concat            (a,b)
  130.  * Concat3            (a,b,c)
  131.  * 
  132.  *
  133.  * The following are in specific <os>Lib.rules:
  134.  *
  135.  * SharedLibraryTarget        (libname,rev,solist,down,up)
  136.  * SharedLibraryDataTarget    (libname,rev,salist)
  137.  * InstallSharedLibrary        (libname,rev,dest)
  138.  * InstallSharedLibraryData    (libname,rev,dest)
  139.  * 
  140.  */
  141.  
  142. #define NullParameter
  143.  
  144. /* if [ -d ] or [ ! -d ] causes make to fail, define this as - */
  145. #ifndef DirFailPrefix
  146. #define DirFailPrefix
  147. #endif
  148.  
  149. /*
  150.  * SaberProgramTarget - generate rules to make Saber-C read in sources and
  151.  * objects.
  152.  */
  153. #ifndef SaberProgramTarget
  154. #if HasSaberC
  155. #define SaberProgramTarget(program,srclist,objlist,locallibs,syslibs)    @@\
  156. Concat(saber_,program):: srclist                    @@\
  157.     XCOMM load $(ALLDEFINES) srclist locallibs $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) syslibs @@\
  158.                                     @@\
  159. Concat(osaber_,program):: objlist                    @@\
  160.     XCOMM load $(ALLDEFINES) objlist locallibs $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) syslibs
  161.  
  162. #else
  163. #define SaberProgramTarget(program,srclist,objlist,locallibs,syslibs) /**/
  164. #endif
  165. #endif
  166.  
  167. #ifndef RemoveTargetProgram
  168. #if RemoveTargetProgramByMoving
  169. #define RemoveTargetProgram(program) \
  170. if [ -f program ]; then $(RM) Concat(program,~); $(MV) program Concat(program,~); fi
  171. #else
  172. #define RemoveTargetProgram(program) $(RM) program
  173. #endif
  174. #endif
  175.  
  176. #ifndef MakeDir
  177. #define MakeDir(dir) DirFailPrefix@if [ -d dir ]; then set +x; \    @@\
  178.         else (set -x; $(MKDIRHIER) dir); fi
  179. #endif
  180.  
  181. #ifndef BuildIncludes
  182. #define BuildIncludes(srclist,dstsubdir,dstupdir)            @@\
  183. includes::                                @@\
  184.     MakeDir($(BUILDINCDIR)/dstsubdir)                @@\
  185.     @(set -x; cd $(BUILDINCDIR)/dstsubdir; for i in srclist; do \    @@\
  186.         $(RM) $$i; \                        @@\
  187.         $(LN) $(BUILDINCTOP)/dstupdir/$(CURRENT_DIR)/$$i .; \    @@\
  188.     done)
  189. #endif /* BuildIncludes */
  190.  
  191. /*
  192.  * NormalProgramTarget - generate rules to compile and link the indicated 
  193.  * program; since it does not use any default object files, it may be used for
  194.  * multiple programs in the same Imakefile.
  195.  */
  196. #ifndef NormalProgramTarget
  197. #define    NormalProgramTarget(program,objects,deplibs,locallibs,syslibs)    @@\
  198. program: objects deplibs                        @@\
  199.     RemoveTargetProgram($@)                        @@\
  200.     $(CC) -o $@ objects $(LDOPTIONS) locallibs $(LDLIBS) syslibs $(EXTRA_LOAD_FLAGS) @@\
  201.                                     @@\
  202. clean::                                    @@\
  203.     $(RM) program
  204. #endif /* NormalProgramTarget */
  205.  
  206.  
  207. #ifndef SetUIDProgramTarget
  208. #define SetUIDProgramTarget NormalProgramTarget
  209. #endif
  210.  
  211.  
  212. /*
  213.  * SingleProgramTarget - obsolete version of NormalProgramTarget that does
  214.  * not have deplibs.
  215.  */
  216. #ifndef SingleProgramTarget
  217. #define    SingleProgramTarget(program,objects,locallibs,syslibs)        @@\
  218. NormalProgramTarget(program,objects,NullParameter,locallibs,syslibs)
  219. #endif /* SingleProgramTarget */
  220.  
  221. /*
  222.  * SimpleProgramTarget - generate rules for compiling and linking programs
  223.  * that only have one C source file.  It should only be used in Imakefiles 
  224.  * that describe a single program.
  225.  */
  226. #ifndef SimpleProgramTarget
  227. #define    SimpleProgramTarget(program)                    @@\
  228.            OBJS = program.o                        @@\
  229.            SRCS = program.c                        @@\
  230.                                     @@\
  231. ComplexProgramTarget(program)
  232. #endif /* SimpleProgramTarget */
  233.  
  234.  
  235.  
  236. /*
  237.  * ComplexProgramTarget - generate rules for compiling and linking the 
  238.  * program specified by $(OBJS) and $(SRCS), installing the program and its
  239.  * man page, and generating dependencies.  It should only be used in 
  240.  * Imakefiles that describe a single program.
  241.  */
  242. #ifndef ComplexProgramTarget
  243. #define    ComplexProgramTarget(program)                    @@\
  244.         PROGRAM = program                        @@\
  245.                                     @@\
  246. AllTarget(program)                            @@\
  247.                                     @@\
  248. program: $(OBJS) $(DEPLIBS)                        @@\
  249.     RemoveTargetProgram($@)                        @@\
  250.     $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) @@\
  251.                                     @@\
  252. SaberProgramTarget(program,$(SRCS),$(OBJS),$(LOCAL_LIBRARIES),NullParameter) @@\
  253.                                     @@\
  254. InstallProgram(program,$(BINDIR))                    @@\
  255. InstallManPage(program,$(MANDIR))                    @@\
  256. DependTarget()                                @@\
  257. LintTarget()                                @@\
  258.                                     @@\
  259. clean::                                    @@\
  260.     $(RM) $(PROGRAM)
  261. #endif /* ComplexProgramTarget */
  262.  
  263.  
  264. /*
  265.  * ComplexProgramTarget_1 - generate rules for compiling and linking the
  266.  * program specified by $(OBJS1) and $(SRCS1), installing the program and its
  267.  * man page, and generating dependencies for it and any programs described
  268.  * by $(SRCS2) and $(SRCS3).  It should be used to build the primary 
  269.  * program in Imakefiles that describe multiple programs.
  270.  */
  271. #ifndef ComplexProgramTarget_1
  272. #define    ComplexProgramTarget_1(program,locallib,syslib)            @@\
  273.             OBJS = $(OBJS1) $(OBJS2) $(OBJS3)                @@\
  274.             SRCS = $(SRCS1) $(SRCS2) $(SRCS3)                @@\
  275.                                     @@\
  276. AllTarget($(PROGRAMS))                            @@\
  277.                                     @@\
  278. program: $(OBJS1) $(DEPLIBS1)                        @@\
  279.     RemoveTargetProgram($@)                        @@\
  280.     $(CC) -o $@ $(LDOPTIONS) $(OBJS1) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
  281.                                     @@\
  282. InstallProgram(program,$(BINDIR))                    @@\
  283. InstallManPage(program,$(MANDIR))                    @@\
  284.                                     @@\
  285. SaberProgramTarget(program,$(SRCS1),$(OBJS1),locallib,syslib)        @@\
  286.                                     @@\
  287. DependTarget()                                @@\
  288. LintTarget()                                @@\
  289.                                     @@\
  290. clean::                                    @@\
  291.     $(RM) $(PROGRAMS)
  292. #endif /* ComplexProgramTarget_1 */
  293.  
  294.  
  295. /*
  296.  * ComplexProgramTarget_2 - generate rules for compiling and linking the
  297.  * program specified by $(OBJS2) and $(SRCS2) and installing the program and
  298.  * man page.  It should be used to build the second program in Imakefiles 
  299.  * describing more than one program.
  300.  */
  301. #ifndef ComplexProgramTarget_2
  302. #define    ComplexProgramTarget_2(program,locallib,syslib)            @@\
  303. program: $(OBJS2) $(DEPLIBS2)                        @@\
  304.     RemoveTargetProgram($@)                        @@\
  305.     $(CC) -o $@ $(LDOPTIONS) $(OBJS2) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
  306.                                     @@\
  307. SaberProgramTarget(program,$(SRCS2),$(OBJS2),locallib,syslib)        @@\
  308.                                     @@\
  309. InstallProgram(program,$(BINDIR))                    @@\
  310. InstallManPage(program,$(MANDIR))
  311. #endif /* ComplexProgramTarget_2 */
  312.  
  313.  
  314. /*
  315.  * ComplexProgramTarget_3 - generate rules for compiling and linking the
  316.  * program specified by $(OBJS3) and $(SRCS3) and installing the program and
  317.  * man page.  It should be used to build the third program in Imakefiles 
  318.  * describing more than one program.
  319.  */
  320. #ifndef ComplexProgramTarget_3
  321. #define    ComplexProgramTarget_3(program,locallib,syslib)            @@\
  322. program: $(OBJS3) $(DEPLIBS3)                        @@\
  323.     RemoveTargetProgram($@)                        @@\
  324.     $(CC) -o $@ $(LDOPTIONS) $(OBJS3) locallib $(LDLIBS) syslib $(EXTRA_LOAD_FLAGS) @@\
  325.                                     @@\
  326. SaberProgramTarget(program,$(SRCS3),$(OBJS3),locallib,syslib)        @@\
  327.                                     @@\
  328. InstallProgram(program,$(BINDIR))                    @@\
  329. InstallManPage(program,$(MANDIR))
  330. #endif /* ComplexProgramTarget_3 */
  331.  
  332.  
  333.  
  334. /*
  335.  * ServerTarget - generate rules to compile, link, and relink an X server.
  336.  */
  337. #ifndef ServerTarget
  338. #define    ServerTarget(server,subdirs,objects,libs,syslibs)        @@\
  339. server: subdirs objects libs                        @@\
  340.     -@if [ -f server ]; then set -x; \                @@\
  341.         $(MV) server server.bak; else exit 0; fi        @@\
  342.     $(CC) $(CDEBUGFLAGS) $(CCOPTIONS) -o server objects libs $(EXTRA_LIBRARIES) syslibs $(EXTRA_LOAD_FLAGS) @@\
  343.                                     @@\
  344. Concat(load,server):                            @@\
  345.     -@if [ -f server ]; then set -x; \                @@\
  346.         $(MV) server server.bak; else exit 0; fi        @@\
  347.     $(CC) $(CDEBUGFLAGS) $(CCOPTIONS) -o server objects libs $(EXTRA_LIBRARIES) syslibs $(EXTRA_LOAD_FLAGS)
  348. #endif /* ServerTarget */
  349.  
  350.  
  351. #if DoRanlibCmd
  352. #define RanLibrary(args) $(RANLIB) args
  353. #else
  354. #define RanLibrary(args) /**/
  355. #endif
  356.  
  357. /*
  358.  * InstallLibrary - generate rules to install the indicated library.
  359.  */
  360. #ifndef InstallLibrary
  361. #define    InstallLibrary(libname,dest)                    @@\
  362. install:: Concat(lib,libname.a)                        @@\
  363.     MakeDir($(DESTDIR)dest)                        @@\
  364.     $(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.a) $(DESTDIR)dest @@\
  365.     RanLibrary($(RANLIBINSTFLAGS) Concat($(DESTDIR)dest/lib,libname.a))
  366. #endif /* InstallLibrary */
  367.  
  368. /*
  369.  * MergeIntoInstalledLibrary - generate rules to merge one library into another
  370.  */
  371. #ifndef MergeIntoInstalledLibrary
  372. #define MergeIntoInstalledLibrary(tolib,fromlib)            @@\
  373. install::  fromlib                            @@\
  374.     $(SCRIPTSRC)/mergelib $(DESTDIR)tolib fromlib
  375. #endif /* MergeIntoInstalledLibrary */
  376.  
  377. /*
  378.  * InstallLibraryAlias - generate rules to create a link from one library name
  379.  * to another for the purposes of aliasing.
  380.  */
  381. #ifndef InstallLibraryAlias
  382. #define    InstallLibraryAlias(libname,alias,dest)                @@\
  383. install::                                @@\
  384.     -(cd $(DESTDIR)dest; \                        @@\
  385.         $(RM) Concat(lib,alias.a); \                @@\
  386.         $(LN) Concat(lib,libname.a) Concat(lib,alias.a))
  387. #endif /* InstallLibraryAlias */
  388.  
  389.  
  390. /*
  391.  * InstallLintLibrary - generate rules to install the indicated lint library.
  392.  */
  393. #ifndef InstallLintLibrary
  394. #define    InstallLintLibrary(libname,dest)                @@\
  395. install.ln:: Concat(llib-l,libname.ln)                    @@\
  396.     MakeDir($(DESTDIR)dest)                        @@\
  397.     $(INSTALL) -c $(INSTLIBFLAGS) Concat(llib-l,libname.ln) $(DESTDIR)dest
  398. #endif /* InstallLintLibrary */
  399.  
  400.  
  401. /*
  402.  * InstallManPageLong - generate rules to install the indicated manual page,
  403.  * giving it an alternate name.  This is used for installing man pages whose
  404.  * base name without the .man suffix would normally be longer than 8 characters
  405.  * (the limit for using source code control systems on files systems with 
  406.  * short file names).
  407.  */
  408. #ifndef InstallManPageLong
  409. #define    InstallManPageLong(file,destdir,dest)                @@\
  410. install.man:: file.man                            @@\
  411.     MakeDir($(DESTDIR)destdir)                    @@\
  412.     $(INSTALL) -c $(INSTMANFLAGS) file.man $(DESTDIR)destdir/dest.$(MANSUFFIX)
  413. #endif /* InstallManPageLong */
  414.  
  415.  
  416. /*
  417.  * InstallManPage - generate rules to install the indicated manual page.
  418.  */
  419. #ifndef InstallManPage
  420. #define    InstallManPage(file,destdir)                    @@\
  421. InstallManPageLong(file,destdir,file)
  422. #endif /* InstallManPage */
  423.  
  424.  
  425. /*
  426.  * InstallManPageAliases - generate rules to install manual page aliases.
  427.  */
  428. #ifndef InstallManPageAliases
  429. #define    InstallManPageAliases(file,destdir,aliases)            @@\
  430. install.man::                                @@\
  431.     @(TMP=/tmp/tmp.$$$$; \                        @@\
  432.     $(RM) $${TMP}; \                        @@\
  433.     echo .so `basename destdir`/file.$(MANSUFFIX) > $${TMP}; \    @@\
  434.     for i in aliases; do (set -x; \                    @@\
  435.     $(INSTALL) -c $(INSTMANFLAGS) $${TMP} $(DESTDIR)destdir/$$i.$(MANSUFFIX)); \ @@\
  436.     done; \                                @@\
  437.     $(RM) $${TMP})
  438. #endif /* InstallManPageAliases */
  439.  
  440.  
  441. /*
  442.  * InstallNamedNonExec - generate rules to install a data file
  443.  */
  444. #ifndef InstallNamedNonExec
  445. #define    InstallNamedNonExec(srcname,dstname,dest)            @@\
  446. install:: srcname                            @@\
  447.     MakeDir($(DESTDIR)dest)                        @@\
  448.     $(INSTALL) -c $(INSTDATFLAGS) srcname $(DESTDIR)dest/dstname
  449. #endif /* InstallNamedNonExec */
  450.  
  451.  
  452. /*
  453.  * InstallNonExecFile - generate rules to install a data file
  454.  */
  455. #ifndef InstallNonExecFile
  456. #define    InstallNonExecFile(file,dest)                    @@\
  457. install:: file                                @@\
  458.     MakeDir($(DESTDIR)dest)                        @@\
  459.     $(INSTALL) -c $(INSTDATFLAGS) file $(DESTDIR)dest
  460. #endif /* InstallNonExecFile */
  461.  
  462.  
  463. /*
  464.  * InstallNonExec - generate rules to install a data file, but does not
  465.  * try to create the destination directory (deprecated)
  466.  */
  467. #ifndef InstallNonExec
  468. #define    InstallNonExec(file,dest)                    @@\
  469. install:: file                                @@\
  470.     $(INSTALL) -c $(INSTDATFLAGS) file $(DESTDIR)dest
  471. #endif /* InstallNonExec */
  472.  
  473.  
  474. /*
  475.  * InstallProgramWithFlags - generate rules to install an executable program
  476.  * using given install flags.
  477.  */
  478. #ifndef InstallProgramWithFlags
  479. #define InstallProgramWithFlags(program,dest,flags)            @@\
  480. install:: program                            @@\
  481.     MakeDir($(DESTDIR)dest)                        @@\
  482.     $(INSTALL) -c $(INSTPGMFLAGS) flags program $(DESTDIR)dest
  483. #endif /* InstallProgramWithFlags */
  484.  
  485.  
  486. /*
  487.  * InstallProgram - generate rules to install an executable program using any
  488.  * special install flags set in $(INSTALLFLAGS).
  489.  */
  490. #ifndef InstallProgram
  491. #define    InstallProgram(program,dest)                    @@\
  492. InstallProgramWithFlags(program,dest,NullParameter)
  493. #endif /* InstallProgram */
  494.  
  495.  
  496.  
  497. /*
  498.  * InstallScript - install a shell script.
  499.  */
  500. #ifndef InstallScript
  501. #define    InstallScript(program,dest)                    @@\
  502. install:: program.script                        @@\
  503.     MakeDir($(DESTDIR)dest)                        @@\
  504.     $(INSTALL) -c $(INSTBINFLAGS) program.script $(DESTDIR)dest/program
  505. #endif /* InstallScript */
  506.  
  507.  
  508. /*
  509.  * InstallNamedProg - install a program with renaming and no stripping.
  510.  */
  511. #ifndef InstallNamedProg
  512. #define    InstallNamedProg(srcname,dstname,dest)                @@\
  513. install:: srcname                            @@\
  514.     MakeDir($(DESTDIR)dest)                        @@\
  515.     $(INSTALL) -c $(INSTBINFLAGS) srcname $(DESTDIR)dest/dstname
  516. #endif /* InstallNamedProg */
  517.  
  518.  
  519. /*
  520.  * LinkFileList - link a list of list of files from one place to another
  521.  */
  522. #ifndef LinkFileList
  523. #define LinkFileList(step,list,dir,sub)                    @@\
  524. step:: list                                @@\
  525.     @case '${MFLAGS}' in *[i]*) set +e;; esac; \            @@\
  526.     echo "    cd" dir; cd dir; \                    @@\
  527.     for i in list; do (set -x; $(RM) $$i; $(LN) sub/$$i .); done
  528. #endif
  529.  
  530.  
  531. /*
  532.  * InstallMultipleDestFlags - generate rules to install multiple files at
  533.  * once during a particular step in the build using a specific set of install 
  534.  * flags.
  535.  */
  536. #ifndef InstallMultipleDestFlags
  537. #define InstallMultipleDestFlags(step,list,dest,flags)            @@\
  538. step:: list                                @@\
  539.     MakeDir($(DESTDIR)dest)                        @@\
  540.     @case '${MFLAGS}' in *[i]*) set +e;; esac; \            @@\
  541.     for i in list; do \                        @@\
  542.         (set -x; $(INSTALL) -c flags $$i $(DESTDIR)dest); \    @@\
  543.     done
  544. #endif /* InstallMultipleDestFlags */
  545.  
  546.  
  547. /*
  548.  * InstallMultipleDest - generate rules to install multiple files at once
  549.  * during a particular step in the build using any install flags set in 
  550.  * $(INSTALLFLAGS).
  551.  */
  552. #ifndef InstallMultipleDest
  553. #define InstallMultipleDest(step,list,dest)                @@\
  554. InstallMultipleDestFlags(step,list,dest,$(INSTALLFLAGS))
  555. #endif /* InstallMultipleDest */
  556.  
  557. /*
  558.  * InstallMultiple - generate rules to install multiple files at once 
  559.  * during the install step of the build using any install flags set in 
  560.  * $(INSTALLFLAGS).
  561.  */
  562. #ifndef InstallMultiple
  563. #define    InstallMultiple(list,dest)                    @@\
  564. InstallMultipleDest(install,list,dest)
  565. #endif /* InstallMultiple */
  566.  
  567.  
  568. /*
  569.  * InstallMultipleFlags - generate rules to install multiple files at once
  570.  * during the install step of the build using the given install flags.
  571.  */
  572. #ifndef InstallMultipleFlags
  573. #define InstallMultipleFlags(list,dest,flags)                @@\
  574. InstallMultipleDestFlags(install,list,dest,flags)
  575. #endif /* InstallMultipleFlags */
  576.  
  577.  
  578. /*
  579.  * InstallMultipleMan - generate rules to install a variety of manual pages
  580.  * during the install.man step of the build.
  581.  */
  582. #ifndef InstallMultipleMan
  583. #define InstallMultipleMan(list,dest)                    @@\
  584. InstallMultipleDestFlags(install.man,list,dest,$(INSTMANFLAGS))
  585. #endif /* InstallMultipleMan */
  586.  
  587.  
  588. /*
  589.  * InstallAppDefaults - generate rules to install appliation default files 
  590.  * if the InstallAppDefFiles configuration parameter is set.
  591.  */
  592. #ifndef InstallAppDefaults
  593. #if InstallAppDefFiles
  594. #define    InstallAppDefaults(class)                    @@\
  595. install:: class.ad                            @@\
  596.     MakeDir($(DESTDIR)$(XAPPLOADDIR))                @@\
  597.     $(INSTALL) -c $(INSTAPPFLAGS) class.ad $(DESTDIR)$(XAPPLOADDIR)/class
  598. #else
  599. #define    InstallAppDefaults(class)
  600. #endif /* InstallAppDefFiles */
  601. #endif /* InstallAppDefaults */
  602.  
  603. /*
  604.  * InstallAppDefaultsLong - generate rules to install appliation default files 
  605.  * if the InstallAppDefFiles configuration parameter is set.
  606.  */
  607. #ifndef InstallAppDefaultsLong
  608. #if InstallAppDefFiles
  609. #define    InstallAppDefaultsLong(file,class)                @@\
  610. install:: file.ad                            @@\
  611.     MakeDir($(DESTDIR)$(XAPPLOADDIR))                @@\
  612.     $(INSTALL) -c $(INSTAPPFLAGS) file.ad $(DESTDIR)$(XAPPLOADDIR)/class
  613. #else
  614. #define    InstallAppDefaultsLong(file,class)
  615. #endif /* InstallAppDefFiles */
  616. #endif /* InstallAppDefaultsLong */
  617.  
  618.  
  619.  
  620.  
  621. /*
  622.  * DependDependency - generate rules to build the makedepend program if 
  623.  * this Imakefile is within the source tree.
  624.  */
  625. #ifndef DependDependency
  626. #ifdef UseInstalled
  627. #define DependDependency() /**/
  628. #else
  629. #define DependDependency()                         @@\
  630. depend:: $(DEPEND)                            @@\
  631.                                     @@\
  632. $(DEPEND):                                @@\
  633.     @echo "checking $@ over in $(DEPENDSRC) first..."; \        @@\
  634.     cd $(DEPENDSRC); $(MAKE); \                    @@\
  635.     echo "okay, continuing in $(CURRENT_DIR)"
  636.  
  637. #endif /* UseInstalled */
  638. #endif /* DependDependency */
  639.  
  640.  
  641. /*
  642.  * DependTarget - generate rules to compute dependencies for all files listed
  643.  * in $(SRCS).
  644.  */
  645. #ifndef DependTarget
  646. #define    DependTarget()                            @@\
  647. DependDependency()                            @@\
  648.                                     @@\
  649. depend::                                @@\
  650.     $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  651. #endif /* DependTarget */
  652.  
  653.  
  654. /*
  655.  * DependTarget3 - generate rules to compute dependencies for all files given.
  656.  */
  657. #ifndef DependTarget3
  658. #define    DependTarget3(srcs1,srcs2,srcs3)                @@\
  659. DependDependency()                            @@\
  660.                                     @@\
  661. depend::                                @@\
  662.     $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- srcs1    @@\
  663.     $(DEPEND) -a $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- srcs2    @@\
  664.     $(DEPEND) -a $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- srcs3
  665. #endif /* DependTarget3 */
  666.  
  667.  
  668. /*
  669.  * CleanTarget - generate rules to remove any garbage files; the #* is here
  670.  * instead of in the definition of RM_CMD because System V will treat the 
  671.  * pound sign in the RM_CMD variable as a comment.
  672.  */
  673. #ifndef CleanTarget
  674. #define    CleanTarget()                            @@\
  675. clean::                                    @@\
  676.     $(RM_CMD) "#"*
  677. #endif /* CleanTarget */
  678.  
  679.  
  680. /*
  681.  * TagsTarget - generate rules to compute tags files for C source code.
  682.  */
  683. #ifndef TagsTarget
  684. #define    TagsTarget()                            @@\
  685. tags::                                    @@\
  686.     $(TAGS) -w *.[ch]                        @@\
  687.     $(TAGS) -xw *.[ch] > TAGS
  688. #endif /* TagsTarget */
  689.  
  690.  
  691. /*
  692.  * ImakeDependency - generate rules to compile imake if this Imakefile is
  693.  * within the source tree.
  694.  */
  695. #ifndef ImakeDependency
  696. #ifdef UseInstalled
  697. #define ImakeDependency(target) /**/
  698. #else
  699. #define ImakeDependency(target)                        @@\
  700. target:: $(IMAKE)                            @@\
  701.                                     @@\
  702. $(IMAKE):                                @@\
  703.     @(cd $(IMAKESRC); if [ -f Makefile ]; then \            @@\
  704.     echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \    @@\
  705.     echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \    @@\
  706.     $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"; fi; \    @@\
  707.     echo "okay, continuing in $(CURRENT_DIR)")
  708. #endif /* UseInstalled */
  709. #endif /* ImakeDependency */
  710.  
  711.  
  712. /*
  713.  * BuildMakefileTarget - generate rules to build a Makefile from an Imakefile
  714.  * and any special imake flags.  This is generally done automatically by the
  715.  * template or by any special Imakefiles.  The first argument exists just
  716.  * because imakeflags is usually empty and some preprocessors will complain
  717.  * if an empty argument is passed as the sole argument to a macro.
  718.  */
  719. #ifndef BuildMakefileTarget
  720. #define    BuildMakefileTarget(notused,imakeflags)                @@\
  721. ImakeDependency(Makefile)                        @@\
  722.                                     @@\
  723. Makefile::                                 @@\
  724.     -@if [ -f Makefile ]; then set -x; \                @@\
  725.         $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \    @@\
  726.     else exit 0; fi                            @@\
  727.     $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) imakeflags
  728.  
  729. #endif /* BuildMakefileTarget */
  730.  
  731.  
  732. /*
  733.  * MakefileTarget - generate rules to build a normal Makefile.
  734.  */
  735. #ifndef MakefileTarget
  736. #define MakefileTarget()                        @@\
  737. BuildMakefileTarget(Imakefile,NullParameter)
  738. #endif /* MakefileTarget */
  739.  
  740.  
  741. /*
  742.  * LibMkdir - helper for creating library object subdirectories
  743.  */
  744. #ifndef LibMkdir
  745. #define LibMkdir(dir) DirFailPrefix@if [ -d dir ]; then exit 0; else set -x; mkdir dir; fi
  746. #endif
  747.  
  748. /*
  749.  * LibCleanDir - helper for cleaning library object subdirectories
  750.  */
  751. #ifndef LibCleanDir
  752. #define LibCleanDir(dir) -@if [ -d dir ]; then \            @@\
  753.         (set -x; cd dir; $(RM) *.o); else exit 0; fi
  754. #endif
  755.  
  756. /*
  757.  * ObjectCompile - compile fragment for a normal object file
  758.  */
  759. #ifndef ObjectCompile
  760. #define ObjectCompile(options) $(RM) $@                    @@\
  761.     $(CC) -c $(CFLAGS) options $*.c
  762. #endif
  763.  
  764. /*
  765.  * NormalLibObjCompile - compile fragment for a normal library object file
  766.  */
  767. #ifndef NormalLibObjCompile
  768. #define NormalLibObjCompile(options) ObjectCompile(options)
  769. #endif
  770.  
  771. /*
  772.  * NormalSharedLibObjCompile - compile fragment for shared object when
  773.  * a normal library is not being built
  774.  */
  775. #ifndef NormalSharedLibObjCompile
  776. #define NormalSharedLibObjCompile(options) NormalLibObjCompile(options $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS))
  777. #endif
  778.  
  779. /*
  780.  * LibObjCompile - compile fragment for shared/profiled/debugged objects
  781.  */
  782. #ifndef LibObjCompile
  783. #define LibObjCompile(dir,options) $(RM) $@ dir/$@            @@\
  784.     $(CC) -c $(CCOPTIONS) $(ALLDEFINES) options $*.c        @@\
  785.     $(MV) $@ dir/$@
  786. #endif
  787.  
  788. /*
  789.  * DebuggedLibObjCompile - compile fragment for debugged objects
  790.  */
  791. #ifndef DebuggedLibObjCompile
  792. #define DebuggedLibObjCompile(options) LibObjCompile(debugger,-g options)
  793. #endif
  794.  
  795. /*
  796.  * ProfiledLibObjCompile - compile fragment for profiled objects
  797.  */
  798. #ifndef ProfiledLibObjCompile
  799. #define ProfiledLibObjCompile(options) LibObjCompile(profiled,-pg options)
  800. #endif
  801.  
  802. /*
  803.  * SharedLibObjCompile - compile fragment for shared objects
  804.  */
  805. #ifndef SharedLibObjCompile
  806. #define SharedLibObjCompile(options) LibObjCompile(shared,options $(SHLIBDEF) $(SHAREDCODEDEF) $(PICFLAGS) $(CDEBUGFLAGS))
  807. #endif
  808.  
  809. /*
  810.  * NormalLibraryObjectRule - for simple libraries
  811.  */
  812. #ifndef NormalLibraryObjectRule
  813. #define    NormalLibraryObjectRule()                    @@\
  814. .c.o:                                    @@\
  815.     ObjectCompile($(_NOOP_))
  816. #endif /* NormalLibraryObjectRule */
  817.  
  818.  
  819. #ifndef NormalFortranObjectRule
  820. #define NormalFortranObjectRule()                    @@\
  821. .f.o:                                    @@\
  822.     $(RM) $@                            @@\
  823.     $(FC) -c $(FCFLAGS) $*.f
  824. #endif
  825.  
  826. #ifndef ObjectFromSpecialSource
  827. #define ObjectFromSpecialSource(dst,src,flags)                @@\
  828. dst.c:  src.c                                @@\
  829.     $(RM) $@                            @@\
  830.     $(LN) $? $@                            @@\
  831.                                     @@\
  832. dst.o:  dst.c                                @@\
  833.     ObjectCompile(flags)                        @@\
  834.                                     @@\
  835. depend::  dst.c                                @@\
  836.                                     @@\
  837. clean::                                    @@\
  838.     $(RM) dst.c
  839. #endif /* ObjectFromSpecialSource */
  840.  
  841. /*
  842.  * SpecialObjectRule - generate rules to compile a file with special flags.
  843.  */
  844. #ifndef SpecialObjectRule
  845. #define SpecialObjectRule(objs,depends,options)                @@\
  846. objs:    depends                                @@\
  847.     ObjectCompile(options)
  848. #endif /* SpecialObjectRule */
  849.  
  850.  
  851. /*
  852.  * NormalLibraryTarget - generate rules to create a library.
  853.  */
  854. #ifndef NormalLibraryTarget
  855. #define    NormalLibraryTarget(libname,objlist)                @@\
  856. AllTarget(Concat(lib,libname.a))                    @@\
  857.                                     @@\
  858. Concat(lib,libname.a): objlist                        @@\
  859.     $(RM) $@                            @@\
  860.     $(AR) $@ objlist                        @@\
  861.     RanLibrary($@)
  862. #endif /* NormalLibraryTarget */
  863.  
  864.  
  865. /*
  866.  * NormalLibraryTarget2 - generate rules to create a library in two steps.
  867.  * This is used to create libraries with large numbers of files.
  868.  */
  869. #ifndef NormalLibraryTarget2
  870. #define    NormalLibraryTarget2(libname,objlist1,objlist2)            @@\
  871. AllTarget(Concat(lib,libname.a))                    @@\
  872.                                     @@\
  873. Concat(lib,libname.a): objlist1 objlist2                @@\
  874.     $(RM) $@                            @@\
  875.     $(AR) $@ objlist1                        @@\
  876.     $(AR) $@ objlist2                        @@\
  877.     RanLibrary($@)
  878. #endif /* NormalLibraryTarget2 */
  879.  
  880.  
  881. /*
  882.  * NormalLibraryTarget3 - generate rules to create a library in three steps.
  883.  * This is used to create libraries with very large numbers of files.
  884.  */
  885. #ifndef NormalLibraryTarget3
  886. #define    NormalLibraryTarget3(libname,objlist1,objlist2,objlist3)    @@\
  887. AllTarget(Concat(lib,libname.a))                    @@\
  888.                                     @@\
  889. Concat(lib,libname.a): objlist1 objlist2 objlist3            @@\
  890.     $(RM) $@                            @@\
  891.     $(AR) $@ objlist1                        @@\
  892.     $(AR) $@ objlist2                        @@\
  893.     $(AR) $@ objlist3                        @@\
  894.     RanLibrary($@)
  895. #endif /* NormalLibraryTarget3 */
  896.  
  897.  
  898. /*
  899.  * NormalDepLibraryTarget - generate rules to create a library.
  900.  */
  901. #ifndef NormalDepLibraryTarget
  902. #define    NormalDepLibraryTarget(libname,deplist,objlist)            @@\
  903. AllTarget(Concat(lib,libname.a))                    @@\
  904.                                     @@\
  905. Concat(lib,libname.a): deplist                        @@\
  906.     $(RM) $@                            @@\
  907.     $(AR) $@ objlist                        @@\
  908.     RanLibrary($@)
  909. #endif /* NormalDepLibraryTarget */
  910.  
  911.  
  912. /*
  913.  * SubdirLibraryRule -
  914.  */
  915. #ifndef SubdirLibraryRule
  916. #define    SubdirLibraryRule(objlist)                    @@\
  917. all:: DONE                                @@\
  918.                                     @@\
  919. DONE: objlist                                @@\
  920.     touch $@                            @@\
  921.                                     @@\
  922. clean::                                    @@\
  923.     $(RM) DONE
  924. #endif /* SubdirLibraryRule */
  925.  
  926.  
  927. /*
  928.  * ProfiledLibraryTarget - generate rules to create a profiled library.
  929.  */
  930. #ifndef ProfiledLibraryTarget
  931. #define    ProfiledLibraryTarget(libname,objlist)                @@\
  932. AllTarget(Concat3(lib,libname,_p.a))                    @@\
  933.                                     @@\
  934. Concat3(lib,libname,_p.a): objlist                    @@\
  935.     $(RM) $@                            @@\
  936.     cd profiled; $(AR) ../$@ objlist                @@\
  937.     RanLibrary($@)
  938.  
  939. #endif /* ProfiledLibraryTarget */
  940.  
  941.  
  942. /*
  943.  * DebuggedLibraryTarget - generate rules to create a debuggable library.
  944.  */
  945. #ifndef DebuggedLibraryTarget
  946. #define    DebuggedLibraryTarget(libname,objlist)                @@\
  947. AllTarget(Concat3(lib,libname,_d.a))                    @@\
  948.                                     @@\
  949. Concat3(lib,libname,_d.a): objlist                    @@\
  950.     $(RM) $@                            @@\
  951.     cd debugger; $(AR) ../$@ objlist                @@\
  952.     RanLibrary($@)
  953.  
  954. #endif /* DebuggedLibraryTarget */
  955.  
  956.  
  957. /*
  958.  * AliasedLibraryTarget - generate rules to link one library to another.
  959.  */
  960. #ifndef AliasedLibraryTarget
  961. #define    AliasedLibraryTarget(libname,alias)                @@\
  962. AllTarget(Concat(lib,alias.a))                        @@\
  963.                                     @@\
  964. Concat(lib,alias.a): Concat(lib,libname.a)                @@\
  965.     $(RM) $@                            @@\
  966.     $(LN) Concat(lib,libname.a) $@
  967. #endif /* AliasedLibraryTarget */
  968.  
  969.  
  970. /*
  971.  * NormalRelocatableTarget - generate rules to produce a relocatable object
  972.  * file instead of a library.  
  973.  */
  974. #ifndef NormalRelocatableTarget
  975. #define    NormalRelocatableTarget(objname,objlist)            @@\
  976. AllTarget(objname.o)                            @@\
  977.                                     @@\
  978. objname.o: objlist                            @@\
  979.     $(RM) $@                            @@\
  980.     $(LD) $(LDCOMBINEFLAGS) objlist -o $@
  981. #endif /* NormalRelocatableTarget */
  982.  
  983.  
  984. /*
  985.  * ProfiledRelocatableTarget - generate rules to produce a profiled relocatable
  986.  * object file instead of a library.
  987.  */
  988. #ifndef ProfiledRelocatableTarget
  989. #define    ProfiledRelocatableTarget(objname,objlist)            @@\
  990. AllTarget(Concat(objname,_p.o))                        @@\
  991.                                     @@\
  992. Concat(objname,_p.o): objlist                        @@\
  993.     $(RM) $@                            @@\
  994.     $(LD) -X -r objlist -o $@
  995.  
  996. #endif /* ProfiledRelocatableTarget */
  997.  
  998.  
  999. /*
  1000.  * DebuggedRelocatableTarget - generate rules to produce a debuggable 
  1001.  * relocatable object file instead of a library.
  1002.  */
  1003. #ifndef DebuggedRelocatableTarget
  1004. #define    DebuggedRelocatableTarget(objname,objlist)            @@\
  1005. AllTarget(Concat(objname,_d.o))                        @@\
  1006.                                     @@\
  1007. Concat(objname,_d.o): objlist                        @@\
  1008.     $(RM) $@                            @@\
  1009.     $(LD) -X -r objlist -o $@
  1010.  
  1011. #endif /* DebuggedRelocatableTarget */
  1012.  
  1013.  
  1014. /*
  1015.  * LintLibraryTarget - generate rules to create a lint library.  Note that the
  1016.  * lint library is always forced to be newer than the library itself.
  1017.  */
  1018. #ifndef LintLibraryTarget
  1019. #define    LintLibraryTarget(libname,srclist)                @@\
  1020. lintlib:: Concat(llib-l,libname.ln)                    @@\
  1021.                                     @@\
  1022. Concat(llib-l,libname.ln): srclist                    @@\
  1023.     $(RM) $@                            @@\
  1024.     $(LINT) Concat($(LINTLIBFLAG),libname) $(LINTFLAGS) srclist
  1025. #endif /* LintLibraryTarget */
  1026.  
  1027.  
  1028. /*
  1029.  * NormalLintTarget - generate rules to lint a set of sources.
  1030.  */
  1031. #ifndef NormalLintTarget
  1032. #define NormalLintTarget(srclist)                    @@\
  1033. lint:                                    @@\
  1034.     $(LINT) $(LINTFLAGS) srclist $(LINTLIBS)            @@\
  1035. lint1:                                    @@\
  1036.     $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  1037. #endif /* NormalLintTarget */
  1038.  
  1039.  
  1040. /*
  1041.  * LintTarget - generate rules to lint $(SRCS)
  1042.  */
  1043. #ifndef LintTarget
  1044. #define LintTarget()                            @@\
  1045. NormalLintTarget($(SRCS))
  1046. #endif
  1047.  
  1048.  
  1049. /*
  1050.  * LinkSourceFile - snag source file from some other directory
  1051.  */
  1052. #ifndef LinkSourceFile
  1053. #define LinkSourceFile(src,dir)                        @@\
  1054. src:  dir/src                                @@\
  1055.     $(RM) $@                            @@\
  1056.     $(LN) $? $@                            @@\
  1057.  
  1058. #endif
  1059.  
  1060.  
  1061. /*
  1062.  * LinkFile - link a file
  1063.  */
  1064. #ifndef LinkFile
  1065. #define LinkFile(tofile,fromfile)                    @@\
  1066. tofile:: fromfile                            @@\
  1067.     $(RM) $@                            @@\
  1068.     $(LN) $? $@
  1069. #endif
  1070.  
  1071.  
  1072. #ifndef MakeSubincludesForBuild
  1073. #define MakeSubincludesForBuild(step,dir,srclist)            @@\
  1074. step::  dir srclist                            @@\
  1075.     @-(list=`echo srclist | sed -e 's/[^ ]*\///g'`; \        @@\
  1076.         set -x; cd dir; $(RM) $$list)                @@\
  1077.     @for i in srclist; do \                        @@\
  1078.         (set -x; cd dir; $(LN) ../$$i .); \            @@\
  1079.     done                                @@\
  1080.                                     @@\
  1081. dir::                                    @@\
  1082.     $(MKDIRHIER) dir                        @@\
  1083.                                     @@\
  1084. clean::                                    @@\
  1085.     @-(if [ -d dir ]; then \                    @@\
  1086.         list=`echo srclist | sed -e 's/[^ ]*\///g'`; \        @@\
  1087.         set -x; cd dir; $(RM) $$list; else exit 0; fi)
  1088. #endif
  1089.  
  1090.  
  1091. /*
  1092.  * NamedTargetSubdirs - recursively make a series of steps
  1093.  */
  1094. #ifndef NamedTargetSubdirs
  1095. #define NamedTargetSubdirs(name,dirs,verb,flags,subname)        @@\
  1096. name::                                    @@\
  1097.     @case '${MFLAGS}' in *[ik]*) set +e;; esac; \            @@\
  1098.     for i in dirs ;\                        @@\
  1099.     do \                                @@\
  1100.         (cd $$i ; echo verb "in $(CURRENT_DIR)/$$i..."; \    @@\
  1101.             $(MAKE) $(MFLAGS) flags subname); \        @@\
  1102.     done
  1103. #endif
  1104.  
  1105.  
  1106. /*
  1107.  * NamedMakeSubdirs - generate rules to do makes in the given subdirectories.
  1108.  * If you want CDEBUGFLAGS passed along to subdirectories, provide a line like
  1109.  * the following in the appropriate Imakefile
  1110.  * 
  1111.  *         #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
  1112.  */
  1113. #ifndef NamedMakeSubdirs
  1114. #define NamedMakeSubdirs(name,dirs) \
  1115. NamedTargetSubdirs(name,dirs,"making" name,PassCDebugFlags,all)
  1116. #endif /* NamedMakeSubdirs */
  1117.  
  1118. #ifndef MakeSubdirs
  1119. #define MakeSubdirs(dirs)                        @@\
  1120. NamedMakeSubdirs(all,dirs)
  1121. #endif /* MakeSubdirs */
  1122.  
  1123.  
  1124. /*
  1125.  * DependSubdirs - generate rules to recursively compute dependencies as
  1126.  * part of the make depend step.
  1127.  */
  1128. #ifndef DependSubdirs
  1129. #define DependSubdirs(dirs) \
  1130. NamedTargetSubdirs(depend,dirs,"depending",NullParameter,depend)
  1131. #endif /* DependSubdirs */
  1132.  
  1133.  
  1134. /*
  1135.  * ForceSubdirs - force make to build subdirectories
  1136.  */
  1137. #ifndef ForceSubdirs
  1138. #define ForceSubdirs(dirs)                        @@\
  1139. dirs: FRC                                @@\
  1140.     @cd $@ ; echo "making all in $(CURRENT_DIR)/$@..."; \        @@\
  1141.     $(MAKE) $(MFLAGS) PassCDebugFlags all                @@\
  1142.                                     @@\
  1143. FRC:
  1144. #endif /* ForceSubdirs */
  1145.  
  1146. /*
  1147.  * InstallSubdirs - generate rules to recursively install programs and files.
  1148.  */
  1149. #ifndef InstallSubdirs
  1150. #define InstallSubdirs(dirs) \
  1151. NamedTargetSubdirs(install,dirs,"installing",DESTDIR='$(DESTDIR)',install)
  1152. #endif /* InstallSubdirs */
  1153.  
  1154.  
  1155. /*
  1156.  * InstallManSubdirs - generate rules to recursively install manual pages.
  1157.  */
  1158. #ifndef InstallManSubdirs
  1159. #define InstallManSubdirs(dirs) \
  1160. NamedTargetSubdirs(install.man,dirs,"installing man pages",DESTDIR='$(DESTDIR)',install.man)
  1161. #endif /* InstallManSubdirs */
  1162.  
  1163.  
  1164. /*
  1165.  * IncludesSubdirs - generate rules to recursively put include files in build
  1166.  */
  1167. #ifndef IncludesSubdirs
  1168. #define IncludesSubdirs(dirs) \
  1169. NamedTargetSubdirs(includes,dirs,including,NullParameter,includes)
  1170. #endif
  1171.  
  1172.  
  1173. /*
  1174.  * CleanSubdirs - generate rules to recursively clean out garbage files.
  1175.  */
  1176. #ifndef NamedCleanSubdirs
  1177. #define NamedCleanSubdirs(name,dirs) \
  1178. NamedTargetSubdirs(name,dirs,"cleaning",RM_CMD='$(RM_CMD)',clean)
  1179. #endif /* NamedCleanSubdirs */
  1180.  
  1181. #ifndef CleanSubdirs
  1182. #define CleanSubdirs(dirs) \
  1183. NamedCleanSubdirs(clean,dirs)
  1184. #endif
  1185.  
  1186.  
  1187. /*
  1188.  * TagSubdirs - generate rules to recursively create tags files.
  1189.  */
  1190. #ifndef NamedTagSubdirs
  1191. #define NamedTagSubdirs(name,dirs) \
  1192. NamedTargetSubdirs(name,dirs,"tagging",TAGS='$(TAGS)',tags)
  1193. #endif /* TagSubdirs */
  1194.  
  1195. #ifndef TagSubdirs
  1196. #define TagSubdirs(dirs) \
  1197. NamedTagSubdirs(tags,dirs)
  1198. #endif
  1199.  
  1200. /*
  1201.  * MakeLintSubdirs - generate rules to recursively lint directories as part 
  1202.  * of the named step.
  1203.  */
  1204. #ifndef MakeLintSubdirs
  1205. #define MakeLintSubdirs(dirs,target,subtarget) \
  1206. NamedTargetSubdirs(target,dirs,"linting" for target and subtarget,DESTDIR='$(DESTDIR)' LINTOPTS='$(LINTOPTS)',subtarget)
  1207. #endif /* MakeLintSubdirs */
  1208.  
  1209.  
  1210. /*
  1211.  * LintSubdirs - generate rules to recursively lint directories as part of 
  1212.  * the make lint step.
  1213.  */
  1214. #ifndef LintSubdirs
  1215. #define LintSubdirs(dirs)                        @@\
  1216. MakeLintSubdirs(dirs,lint,lint)
  1217. #endif /* LintSubdirs */
  1218.  
  1219.  
  1220. /*
  1221.  * MakeLintLibSubdirs - generate rules to recursively create lint libraries.
  1222.  */
  1223. #ifndef MakeLintLibSubdirs
  1224. #define MakeLintLibSubdirs(dirs)                    @@\
  1225. MakeLintSubdirs(dirs,lintlib,lintlib)
  1226. #endif /* MakeLintLibSubdirs */
  1227.  
  1228.  
  1229. /*
  1230.  * MakeMakeSubdirs - generate rules to recursively recreate Makefiles as part
  1231.  * of the specified step in the build.  If $(TOP) is set to an absolute path, 
  1232.  * do not prepend the ../ prefix.  This makes running things outside of the 
  1233.  * source tree to be much easier.
  1234.  */
  1235. #ifndef MakeMakeSubdirs
  1236. #define MakeMakeSubdirs(dirs,target)                    @@\
  1237. target::                                @@\
  1238.     @case '${MFLAGS}' in *[ik]*) set +e;; esac; \            @@\
  1239.     for i in dirs ;\                        @@\
  1240.     do \                                @@\
  1241.         echo "making Makefiles in $(CURRENT_DIR)/$$i..."; \    @@\
  1242.         case "$$i" in \                        @@\
  1243.         ./?*/?*/?*/?*) newtop=../../../../ sub=subsubsubsub;; \    @@\
  1244.         ./?*/?*/?*) newtop=../../../ sub=subsubsub;; \        @@\
  1245.         ./?*/?*)    newtop=../../ sub=subsub;; \        @@\
  1246.         ./?*)       newtop=../ sub=sub;; \            @@\
  1247.         */?*/?*/?*)    newtop=../../../../ sub=subsubsubsub;; \    @@\
  1248.         */?*/?*)    newtop=../../../ sub=subsubsub;; \        @@\
  1249.         */?*)       newtop=../../ sub=subsub;; \        @@\
  1250.         *)        newtop=../ sub=sub;; \            @@\
  1251.         esac; \                            @@\
  1252.         case "$(TOP)" in \                    @@\
  1253.         /?*) newtop=  upprefix=  ;; \                @@\
  1254.         *) upprefix=../ ;; \                    @@\
  1255.         esac; \                            @@\
  1256.         $(MAKE) $${sub}dirMakefiles UPPREFIX=$$upprefix NEWTOP=$$newtop \        @@\
  1257.         MAKEFILE_SUBDIR=$$i NEW_CURRENT_DIR=$(CURRENT_DIR)/$$i;\ @@\
  1258.     done
  1259. #endif /* MakeMakeSubdirs */
  1260.  
  1261.  
  1262. /*
  1263.  * MakeNsubdirMakefiles - generate rules to create sub Makefiles.
  1264.  */
  1265. #ifndef MakeNsubdirMakefiles
  1266. #define MakeNsubdirMakefiles()                        @@\
  1267. subdirMakefiles:                            @@\
  1268.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1269.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1270.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1271.     else exit 0; fi                            @@\
  1272.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1273.     $(MAKE) $(MFLAGS) Makefiles                     @@\
  1274.                                     @@\
  1275. subsubdirMakefiles:                            @@\
  1276.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1277.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1278.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1279.     else exit 0; fi                            @@\
  1280.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1281.     $(MAKE) $(MFLAGS) Makefiles                     @@\
  1282.                                     @@\
  1283. subsubsubdirMakefiles:                            @@\
  1284.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1285.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1286.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1287.     else exit 0; fi @@\
  1288.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1289.     $(MAKE) $(MFLAGS) Makefiles                     @@\
  1290.                                     @@\
  1291. subsubsubsubdirMakefiles:                        @@\
  1292.     $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                @@\
  1293.     -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \        @@\
  1294.     $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
  1295.     else exit 0; fi                         @@\
  1296.     cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \    @@\
  1297.     $(MAKE) $(MFLAGS) Makefiles
  1298. #endif /* MakeNsubdirMakefiles */
  1299.  
  1300.  
  1301. /*
  1302.  * MakefileSubdirs - generate rules to create Makefiles.
  1303.  */
  1304. #ifndef MakefileSubdirs
  1305. #define MakefileSubdirs(dirs)                        @@\
  1306. MakeMakeSubdirs(dirs,Makefiles)                        @@\
  1307.                                     @@\
  1308. MakeNsubdirMakefiles()
  1309. #endif /* MakefileSubdirs */
  1310.  
  1311. /*
  1312.  * Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
  1313.  * to cpp, because that trick does not work on all ANSI C preprocessors.
  1314.  * Also delete line numbers from the cpp output (-P is not portable, I guess).
  1315.  */
  1316. #ifndef CppSedMagic
  1317. #define CppSedMagic sed -e '/^#  *[0-9][0-9]*  *.*$$/d' \
  1318.             -e '/^XCOMM$$/s//#/' \
  1319.             -e '/^XCOMM[^a-zA-Z0-9_]/s/^XCOMM/#/'
  1320. #endif /* CppSedMagic */
  1321.  
  1322. /*
  1323.  * CppScriptTarget - generate rules to create a shell script by running the
  1324.  * input through cpp.  If the ExecableScripts configuration parameter is not
  1325.  * set, then make sure that the first line begins with a colon.
  1326.  */
  1327. #ifndef CppScriptTarget
  1328. #if ExecableScripts        /* can use #! instead of colon */
  1329. #define CppScriptTarget(dst,src,defs,deplist)                @@\
  1330. dst::  src deplist                            @@\
  1331.     $(RM) $@                            @@\
  1332.     $(CPP) defs <src | CppSedMagic >$@                @@\
  1333.     chmod a+x $@
  1334. #else
  1335. #define CppScriptTarget(dst,src,defs,deplist)                @@\
  1336. dst::  src deplist                            @@\
  1337.     $(RM) $@                            @@\
  1338.     echo \: >$@                            @@\
  1339.     sed '1d' src | $(CPP) defs | CppSedMagic >>$@            @@\
  1340.     chmod a+x $@
  1341. #endif /* ExecableScripts */
  1342. #endif /* CppScriptTarget */
  1343.  
  1344.  
  1345. /*
  1346.  * MakeScriptFromCpp - generate rules to create a script from a file with a
  1347.  * .cpp suffix.
  1348.  */
  1349. #ifndef MakeScriptFromCpp
  1350. #define MakeScriptFromCpp(name,defs)                    @@\
  1351. CppScriptTarget(name,name.cpp,defs,NullParameter)
  1352. #endif /* MakeScriptFromCpp */
  1353.  
  1354. #ifndef CppFileTarget
  1355. #define CppFileTarget(dst,src,defs,deplist)                @@\
  1356. dst::  src deplist                            @@\
  1357.     $(RM) $@                            @@\
  1358.     $(CPP) defs <src | CppSedMagic >$@
  1359. #endif /* CppFileTarget */
  1360.  
  1361. /*
  1362.  * MakeDirectories - generate rules to create a hierarchy of directories.
  1363.  */
  1364. #ifndef MakeDirectories
  1365. #define MakeDirectories(step,dirs)                    @@\
  1366. step::                                    @@\
  1367.     @case '${MFLAGS}' in *[i]*) set +e;; esac;            @@\
  1368.     DirFailPrefix@for i in dirs; do if [ -d $(DESTDIR)$$i ]; then \    @@\
  1369.         set +x; else (set -x; $(MKDIRHIER) $(DESTDIR)$$i); fi \    @@\
  1370.     done
  1371. #endif /* MakeDirectories */
  1372.  
  1373.  
  1374. /*
  1375.  * MakeFontsDir - generate rules to build fonts.dir database.
  1376.  */
  1377. #ifndef MakeFontsDir
  1378. #define MakeFontsDir(deplist)                        @@\
  1379. all:: fonts.dir                                @@\
  1380.                                     @@\
  1381. fonts.dir:  deplist                            @@\
  1382.     $(MKFONTDIR) .                            @@\
  1383.                                     @@\
  1384. clean::                                    @@\
  1385.     $(RM) fonts.dir
  1386. #endif /* MakeFontsDir */
  1387.  
  1388.  
  1389. /*
  1390.  * MakeFonts - generate rules to build font database.
  1391.  */
  1392. #ifndef MakeFonts
  1393. #define MakeFonts()                            @@\
  1394. all::  $(OBJS)                                @@\
  1395.                                     @@\
  1396. MakeFontsDir($(OBJS))                            @@\
  1397.                                     @@\
  1398. clean::                                    @@\
  1399.     $(RM) *.snf *.snf.Z *.pcf *.pcf.Z
  1400. #endif /* MakeFonts */
  1401.  
  1402.  
  1403. /*
  1404.  * InstallFontObjs - generate rules to install font files
  1405.  */
  1406. #ifndef InstallFontObjs
  1407. #define InstallFontObjs(objs,dest)                    @@\
  1408. InstallMultipleFlags(objs,dest,$(INSTDATFLAGS))                @@\
  1409.                                     @@\
  1410. install::  fonts.dir                            @@\
  1411.     MakeDir($(DESTDIR)dest)                        @@\
  1412.     $(INSTALL) -c $(INSTDATFLAGS) fonts.dir $(DESTDIR)dest
  1413. #endif /* InstallFontObjs */
  1414.  
  1415.  
  1416. /*
  1417.  * InstallFonts - generate rules to install font files
  1418.  */
  1419. #ifndef InstallFonts
  1420. #define InstallFonts(dest)                        @@\
  1421. InstallFontObjs($(OBJS),dest)
  1422. #endif /* InstallFonts */
  1423.  
  1424.  
  1425. /*
  1426.  * InstallFontAliases - generate rules to install font aliases databases. 
  1427.  */
  1428. #ifndef InstallFontAliases
  1429. #define InstallFontAliases(dest)                    @@\
  1430. install::  fonts.alias                            @@\
  1431.     MakeDir($(DESTDIR)dest)                        @@\
  1432.     $(INSTALL) -c $(INSTDATFLAGS) fonts.alias $(DESTDIR)dest
  1433. #endif /* InstallFontAliases */
  1434.  
  1435. #ifndef FontSrc
  1436. #define FontSrc(basename) basename.bdf
  1437. #endif
  1438.  
  1439. #ifndef FontBaseObj
  1440. #ifdef SnfFonts
  1441. #define FontBaseObj(basename)basename.snf
  1442. #else
  1443. #define FontBaseObj(basename)basename.pcf
  1444. #endif
  1445. #endif
  1446.  
  1447. /*
  1448.  * InstallFontScale - generate rules to install font scale database.
  1449.  */
  1450. #ifndef InstallFontScale
  1451. #define InstallFontScale(dest)                        @@\
  1452. install::  fonts.scale                            @@\
  1453.     MakeDir($(DESTDIR)dest)                        @@\
  1454.     $(INSTALL) -c $(INSTDATFLAGS) fonts.scale $(DESTDIR)dest
  1455. #endif /* InstallFontScale */
  1456.  
  1457. /*
  1458.  * UncompressedFontTarget
  1459.  */
  1460. #ifndef UncompressedFontTarget
  1461. #ifdef SnfFonts
  1462. #define UncompressedFontTarget(basename)                @@\
  1463. FontBaseObj(basename):  FontSrc(basename)                @@\
  1464.     $(FONTC) $(FONTCFLAGS) $? >$@
  1465. #else
  1466. #define UncompressedFontTarget(basename)                @@\
  1467. FontBaseObj(basename):  FontSrc(basename)                @@\
  1468.     $(FONTC) $(FONTCFLAGS) $? -o $@
  1469. #endif
  1470. #endif /* CompressedFontTarget */
  1471.  
  1472. /*
  1473.  * CompressedFontTarget
  1474.  */
  1475. #ifndef CompressedFontTarget
  1476. #define CompressedFontTarget(basename)                    @@\
  1477. FontBaseObj(basename).Z:  FontSrc(basename)                @@\
  1478.     $(FONTC) $(FONTCFLAGS) $? | $(COMPRESS) > $@
  1479. #endif /* CompressedFontTarget */
  1480.  
  1481. #ifdef CompressAllFonts
  1482. #define FontTarget(basename) CompressedFontTarget(basename)
  1483. #define FontObj(basename) FontBaseObj(basename).Z
  1484. #else
  1485. #define FontTarget(basename) UncompressedFontTarget(basename)
  1486. #define FontObj(basename) FontBaseObj(basename)
  1487. #endif /* CompressAllFonts */
  1488.  
  1489. /*
  1490.  * AllTarget - generate rules to build necessary things during make all.
  1491.  */
  1492. #ifndef AllTarget
  1493. #define AllTarget(depends)                        @@\
  1494. all:: depends
  1495. #endif /* AllTarget */
  1496.  
  1497. #ifdef DefineOldLibraryRules
  1498. #include <oldlib.rules>
  1499. #endif
  1500.